<title>表同步监控</title>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div style="padding-bottom: 10px;">
                <button class="layui-btn layuiadmin-btn-bjk-info mybtn" data-type="reload">刷新</button>
                <button class="layui-btn layuiadmin-btn-bjk-info mybtn" lay-filter="LAY-bjk-info-front-search"
                        data-type="mohu"
                        style="float: right;margin: 0">
                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                </button>

                <input style="width: 200px; float: right " type="text" onclick=""
                       name="bjkinfo"
                       value="" placeholder="请输入要查询的数据表名"
                       autocomplete="off"
                       class="layui-form layui-input">
            </div>

            <table  id="Nsr-bjk" lay-filter="Nsr-bjk"></table>
        </div>
    </div>
</div>

<script>

    layui.use(['form', 'table', 'admin', 'view', 'upload'], function () {
        var $ = layui.$
            , form = layui.form
            , table = layui.table
            , admin = layui.admin
            , view = layui.view
            , upload = layui.upload
            , loadIndex;
        let myAuthorization = layui.data('layuiAdmin', 'Authorization')
        table.set({
            headers: { //通过 request 头传递
                Authorization: layui.data('layuiAdmin').Authorization
            }
        });

        table.render({
            elem: '#Nsr-bjk'
            // , url: './json/basicinformation/xc_info.json' //模拟接口
            , url: layui.setter.hostAddr + '/portal/table' //接口
            // , toolbar: '#risk-tool'
            , cols: [[
                // {type: 'checkbox', fixed: 'center'},
                {field: 'tableName',  title: '数据表名称', align: 'center'}
                , {field: 'description', title: '数据表注释',  align: 'center'}
                , { field: 'maxTbsj', title: '最后一次同步时间', align: 'center' }
            ]]
            , page: true
            , limit: 10
            , text: '对不起，加载出现异常！'
        });


        var active = {
            reload: function () {
                table.reload('Nsr-bjk', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: {
                        keyword: ""
                    }
                });
            },
            mohu: function () {
                // alert('mohu')
                var xcInfoVal = $("input[name='bjkinfo']").val()
                //执行重载
                table.reload('Nsr-bjk', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: {
                        keyword: xcInfoVal
                    }
                });
            },
        }
        $('.layui-btn.layuiadmin-btn-bjk-info').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    })

</script>